﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics.Contracts;

namespace Bank.Operations
{
    public class SimpleInterestCalculator : IInterestCalculator
    {
        private decimal _interestAmount;

        public SimpleInterestCalculator()
            : this(0.05m) { }

        public SimpleInterestCalculator(decimal interestAmount)
        {
            Contract.Requires(interestAmount > 0m);

            _interestAmount = interestAmount;
        }

        public void CalculateInterest(IAccount account)
        {
            Contract.Requires(account != null);
            Contract.Requires(account.Ballance > 0m);

            var result = Math.Round((account.Ballance * _interestAmount), 2);

            account.Ballance += result;
        }

        public void CalculateInterest2(IAccount account)
        {
            Contract.Requires(account != null);
            Contract.Requires(account.Ballance2 > 0m);

            var result = Money.Round((account.Ballance2 * _interestAmount), 2);

            account.Ballance2 += result;
        }
    }
}
